import math
from matplotlib import pyplot
dir='/home/jcfernandez/resultados/eps5/u0/AMPL/W2.0/CONNECT/'
cuales=['0.05','0.1','0.2','0.5','1','2','5','10','20','40','60','100','200']
cuales=['0.05','0.1','0.2','0.5','1','2','5','10','20','40','60','100','200']
cabecera='conHVA'
tlimit=100.0

f = open(dir+'conectLimit.dat','w')
for i in range(len(cuales)):
    name=cabecera+cuales[i]+'.dat'
    HH=0.0
    VV=0.0
    n=0.0
    for line in file(dir+name):
        line=line.replace('\n','')
        res=[]
        val=line.split(' ')
        for v in val:
            if v !='':
                res.append(float(v))
        if res[0]>tlimit:
            HH+=res[1]
            VV+=res[2]
            n+=1.0
    if n==0:
        pass
    else:
        f.write(cuales[i]+' '+str(HH/n)+' '+str(VV/n)+'\n');
f.close()
            